package util;

import java.util.ArrayList;
import java.util.List;

public class PermutationNum {

	private static long res = 0;
	
	public static long calculateRes(int n, int m){
		res = 0;
		//n! / ((n - m)!) 
		List<Integer> list = new ArrayList<Integer>();
		help(list, m, n);
		return res;
	}
	
	private static void help(List<Integer> list, int m, int n){
		if(list.size() == m){
			res++;
			return;
		}
		for (int i = 1; i <= n; i++) {
			if(list.contains(i)){
				continue;
			}
			list.add(i);
			help(list, m, n);
			list.remove(list.size() - 1);
		}
	}
}
